function doValidate() {
    $.validity.start();
    $("#name").require("请输入角色名称").maxLength(50,"最长50");
    $("#memo").maxLength(200,"最长200");
    var result = $.validity.end();
    return result.valid;
}

$(function(){
    $('form').submit(function(){
        if(doValidate()){
            $('input[name="dictionaryType.treeStructure"]').val($('#treeStructure:checked').length>0);
            $('input[type="submit"]').attr("disabled","disabled");
            $.ajax({
                type: 'POST',
                url: $('form').attr('action'),
                data: $('form').serialize(),
                success: function(data){
                    if(data.ok){
                        showMessage('新字典类型创建成功',function(){closeDialog();});
                    }else{
                        showMessage('新字典类型创建失败：'+data.message,null,'error');
                    }
                },
                complete:function() {
                    $('input[type="submit"]').removeAttr("disabled");
                }
            });
        }
        return false;
    });
});